home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
CUGUK
/
APPLICAT
/
C034.ZIP
/
DEMO.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
2010-11-01
|
3KB
|
225 lines
set verify;
define etc
enter continue:
#
# THIS IS A DEMONSTRATION OF SETTING UP TWO SMALL
# DATABASES AND APPLYING A RELATIONAL JOIN ACROSS THEM.
#
# When the Enter continue prompt is given, you may press
# ENTER when ready to proceed.
#
# FIRST - CREATE CARS DATABASE
#
etc
create cars
make char 10
model char 11
capacity num 5
mpg num 2
price num 8 2
;
#
# NOW WE'LL INSERT SOME CARS
#
etc
insert cars
Ford
Escort L
1300
45
4300.53
Vauxhall
Cavalier
1600
39
5600.67
Ferrari
Gt30
5400
18
23000.45
Austin
Allegro
1300
50
3400.23
Porche
911
2400
32
5600.50
Seat
1100
1100
45
2300.45
#
# NOW PRINT THEM IN TABULAR FORM
#
etc
print cars;
#
# AND SORT THEM
#
etc
sort cars by make, model, capacity;
print cars;
#
# NOW WE'LL DO A SELECTION OF CHEAP ONES
# AND TOTAL UP THEIR PRICES
#
etc
print make, model, price+ of cars with price < 5000;
#
# NOW WE'LL CREATE A SECOND DATABASE OF MAKERS
#
etc
create makers
maker
char 10
country char 10
;
#
# AND INSERT SOME MAKERS
#
insert makers
Ford
britain
Austin
britain
Vauxhall
britain
Ferrari
italy
Fiat
italy
Porche
germany
Renault
france
Seat
spain
Citroen
france
Rover
britain
#
# SORT THEM
#
etc
sort makers by maker;
print makers;
#
# NOW WE'LL JOIN THE TWO DATABASES
#
etc
print make, model, price, country of cars, makers
with make = maker;
#
# ADD A FEW MORE CARS
#
etc
insert cars
Fiat
Strada
1700
34
4500.65
Renault
5
1100
56
5600.56
Rover
100
2000
35
6700.62
Austin
Westminster
3000
22
500.23
Citroen
2CV
23
98
1300.73
sort cars by make, model
;
#
# NOW DEFINE A MACRO FOR DOING JOIN
#
define ourcars
make, model, capacity, mpg, price
of cars, makers
with make = maker
and country = "britain";
#
# PRINT USING THE MACRO
#
etc
print ourcars
#
# DO ANOTHER LITTLE SELECTION
#
etc
print maker of makers with country = "britain";
#
# Now we'll demonstrate the format files
#
# FIRST A FORMATTED TABULATION
#
etc
set page 8;
print using cars cars;
etc
#
# WE'LL DEMONSTRATE FINDING A SELECTION
# TO A 'CURRENT' DATABASE
#
find cars with capacity > 2000;
#
# AND PRINT IT (NOTE: PRINT STATEMENT DEFAULTS TO CURRENT DATABASE)
#
etc
print;
#
# AND WE WILL RENAME THEM TO MAKE THEM PERMANENT
#
etc
rename current bigcars;
#
# NOW PRINT ECONOMICAL BIG CARS IN A FORM LETTER
#
etc
print using letter bigcars with mpg > 30;
#
# JUST TO SHOW THEY ARE NOT THAT PERMANENT :-
#
etc
erase bigcars
#
# DEMO OF HOW TO PRODUCE FILE SUITABLE FOR INPUT TO
# BASIC (OR ONE OF THE PRODUCTS SUPPORTING COMMA
# SEPARATED DATA - SUCH AS DBASE II OR SUPERCALC).
#
# TYPE OUT FILE "CARS.DAT" WHEN FINISHED
#
etc
print using tobasic cars into "cars.dat";
#
# OVER TO YOU NOW
# (Type 'exit' when finished)
#
# To delete demo databases, type
#
# dbq> erase cars
# dbq> erase makers
#
TO YOU N